/**
 * @file m1083.c
 * @brief H3D1 keypad driver
 *
 * @author yemt@witsi.cn
 * @date 2014-05-25
 * @version H3D1.keypad.01
 */
#include "dev.h"
#include <key.h>
#include <sys/ioctl.h>
#include "arch.h"
#include "init.h"
#include "syscfg.h"
#include "iodev.h"
#include "config.h"
#include "kernel.h"
#include "dev.h"

#ifdef CONFIG_POWER_KEY
static void power_key_interrupt(void)
{
        enable_nvsram_32k();
        mdelay(1000);
        power_off();
}

static int pwkey_init(iodev_t *dev)
{

        gpio_set_input(CONFIG_POWER_KEY, 0);	    
        gpio_request_irq(CONFIG_POWER_KEY, GPIO_INT_FALLING, power_key_interrupt);

        gpio_irq_enable(CONFIG_POWER_KEY);
        return 0;
}


static const iodev_t m1033_key __iodev_entry = {
        .name = "powerkey",
        .priv = NULL,
        .init = pwkey_init,
        .read = NULL,
        .write = NULL,
        .ioctl = NULL,
        .poll = NULL,
};
#endif

